//
//  MYXNewCodeView.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/11/27.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "MYXNewCodeView.h"
#import "UIView+Extension.h"

@interface MYXNewCodeView () <UITextFieldDelegate>

@end


@implementation MYXNewCodeView
- (IBAction)sureB:(UIButton *)sender {
     [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
    
    if (KPhoneNumIsRight(self.iphoneTF.text)) {
        [[MYXHttpManager shared] addMyBossWithPhone:self.iphoneTF.text withResult:^(BOOL sucess, NSString *msg) {
            if (sucess) {
                [self.mSuperVC showSuccessTopMessage:msg];
                [self.mSuperVC.navigationController popViewControllerAnimated:YES];
            }else{
                [self.mSuperVC showFailureTopMessage:msg];
            }
        }];
    }
}
#pragma mark  - 私有方法
/** 键盘弹出 */
- (void)showKeyboard {
    [self.iphoneTF becomeFirstResponder];
    [UIView animateWithDuration:CYPasswordViewAnimationDuration delay:0 options:UIViewAnimationOptionTransitionNone animations:^{
        self.iphoneTF.y = (self.height - self.iphoneTF.height);
    } completion:^(BOOL finished) {
        CYLog(@"%@", NSStringFromCGRect(self.iphoneTF.frame));
    }];
}

/** 键盘退下 */
- (void)hideKeyboard:(void (^)(BOOL finished))completion {
    [self.iphoneTF endEditing:NO];
    [UIView animateWithDuration:CYPasswordViewAnimationDuration delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        self.inputView.transform = CGAffineTransformIdentity;
    } completion:completion];
}

#pragma mark  - <UITextFieldDelegate>
#pragma mark  处理字符串 和 删除键
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    
    return YES;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
